/*
 * Sesame Inc.
 * Copyright (c) 2009 All Rights Reserved.
 */
package com.sesame.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.context.SecurityContextHolder;
import org.springframework.security.userdetails.UserDetails;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import com.sesame.domain.AlbumTag;
import com.sesame.domain.Image;
import com.sesame.domain.ImageTag;
import com.sesame.domain.Notice;
import com.sesame.domain.TagCloud;
import com.sesame.domain.User;
import com.sesame.domain.Album;
import com.sesame.domain.Guestbook;
import com.sesame.service.AlbumService;
import com.sesame.service.ContactService;
import com.sesame.service.MessageService;
import com.sesame.service.PageService;
import com.sesame.service.UserService;
import com.sesame.toolkit.Page;

/**
 * @author shubeta
 * 
 */
public class GuestHomeController extends AbstractController {

    private UserService userService;
    private AlbumService albumService;
    private ContactService contactService;
    private MessageService messageService;
    private PageService pageService;

    public void setPageService(PageService pageService) {
        this.pageService = pageService;
    }

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    public void setAlbumService(AlbumService albumService) {
        this.albumService = albumService;
    }

    public void setContactService(ContactService contactService) {
        this.contactService = contactService;
    }

    public void setMessageService(MessageService messageService) {
        this.messageService = messageService;
    }

    protected ModelAndView handleRequestInternal(HttpServletRequest request,
            HttpServletResponse response) throws Exception {

        Map model = new HashMap();
        List<Album> albumList = albumService.listAllAlbum();
        List<Album> albumHotList = albumService.listTopAlbum();
        List<Image> imageList = albumService.listAllImage();
        List<Image> imageHotList = albumService.listTopImage();
        List<User> userList = contactService.listAllUser();
        List<TagCloud> tagCloudList = albumService.listAllAlbumTag();
        List<TagCloud> imageTagList = albumService.listAllImageTag();
        List<Notice> noticeList = userService.listTopNotice();

        model.put("albumList", albumList);
        model.put("albumHotList", albumHotList);
        model.put("imageList", imageList);
        model.put("imageHotList", imageHotList);
        model.put("userList", userList);
        model.put("tagCloudList", tagCloudList);
        model.put("imageTagList", imageTagList);
        model.put("noticeList", noticeList);

        return new ModelAndView("guestHome", model);

    }

}